"-------------------------------------------------------------------------------
"

" Call a funcution only if it exists.
func! CallIf(funcname, arglist)
    if exists("*".a:funcname)
        return call(a:funcname, a:arglist)
    endif
endfunc

" Call a funcution only once.
func! CallOnce(funcname, arglist)
    let l:flag = "g:called_".a:funcname
    if !exists("*".a:funcname) || exists(l:flag)
        return
    endif
    exec "let ".l:flag."=1"
    return call(a:funcname, a:arglist)
endfunc

"-------------------------------------------------------------------------------
" encoding, font, etc.

" normally 'encoding' will be equal to your current locale.
" you can detect the locale via v:lang, e.g.,
"     if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
" and export LANG=... in ~/.bashrc to set the locale, e.g.,
"     export LANG=zh_CN.utf8
" you don't have to set it.
"set fileencodings=utf-8,ucs-bom,cp936,gbk,gb2312,big5,latin1
set fileencodings=utf-8,ucs-bom,gbk,gb2312,big5,latin1

if has("gui_running")
    " I always use Vim in console in Linux so this is only for gVim in Windows.
    if has("gui_win32")
        set guifont=DejaVu_Sans_Mono:h11:cDEFAULT,Courier_New:h11:cDEFAULT
        " Need to download 'GB18030 Support Package' from MS.com for SimSun-18030.
        " Make sure 'encoding' is "utf-8" and "guifontset" is empty or invalid. (except GTK+ 2)
        "set guifontwide=SimSun-18030,Arial_Unicode_MS
        " Prefer console style UI.
        set guioptions-=e " use console style tab
        set guioptions-=T " no toolbar
        set guioptions-=m " no menu
    elseif has("gui_macvim")
        set guifont=Andale\ Mono:h13,Courier\ New:h13
    endif
endif

" for chinese
set formatoptions+=mM

"set listchars=trail:-

"-------------------------------------------------------------------------------
" general

set nocompatible
set history=400

set nobackup
set nowritebackup
set noswapfile

set autoread " when file is changed outside
" Persistent undo serializes to a file named '.<filename>.un~'.
" That's a little anoying.
if v:version >= 730
"    set undofile " .
endif

" Go language vim files. Set before "filetype plugin indent on".
if $GOROOT != ""
  set rtp+=$GOROOT/misc/vim
endif

" Enable file type detection.
" Use the default filetype settings. Also load indent files to automatically
" do language-dependent indenting ('cindent' for C, C++, Java, C# files).
filetype plugin on
filetype indent on

let mapleader = ","
let g:mapleader = ","

nmap <leader>w :w!<CR>
nmap <leader>f :find<CR>

set ffs=dos,unix,mac
nmap <leader>fd :set ff=dos<CR>
nmap <leader>fu :set ff=unix<CR>

" Remove the Windows ^M
noremap <leader>m :%s/<C-V><C-M>//ge<CR>

" Restore cursor to file position in previous editing session.
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

" Automatically save and restore views for files.
" NOTE: Using * instead of ?* causes error.
"au BufWinLeave ?* mkview
"au BufWinEnter ?* silent loadview

" Display dynamic information in tooltip based on where the mouse is pointing.
if has("balloon_eval")
    set ballooneval
endif

" TODO
"inoremap <tab> <C-X><C-I>

" Use / instead of \ when get path from getcwd(), expand(), etc.
" With this option set, escape() doens't have to care about '\' in Windows.
set shellslash

"-------------------------------------------------------------------------------
" format

"set autoindent
"set smartindent

" t0: no indent for function return type declaration.
" g0: no indent for C++ scope declarations ('public:' 'private:' etc.)
" :0: no indent for labels of switch().
set cinoptions=t0,g0,:0

" Note: After expanding tab, type "C-v tab" to get the unexpanded tab.
" If you have a file that already contains tabs then you can convert them to spaces by typing :retab.
" :retab replaces a tab with &tabstop(ts) number of spaces.
func! ExpandTab(tabsize)
"     for tabstop: default 8. better not to change it
    exec ":set expandtab"
    exec ":set shiftwidth=" . a:tabsize
    exec ":set softtabstop=" . a:tabsize
endfunc

" TODO
call ExpandTab(4) " default
au FileType c,cpp,vim,html,lua call ExpandTab(2)
nnoremap <leader>t2 call ExpandTab(2)
nnoremap <leader>t4 call ExpandTab(4)

"set smarttab

" linebreak makes sense only when wrap is on & list is off(nolist)
set linebreak
" textwidth is useful to formating comments.
"set textwidth=80
set nowrap " lines (nowrap)
" colorcolumn highlights the specified column(s) but it makes redrawing slower.
"set colorcolumn=<nr>[,<nr>]

"-------------------------------------------------------------------------------
" color

if &t_Co > 2 || has("gui_running")
    set background=dark
    syntax enable
    colorscheme desert
    au BufEnter * :syntax sync fromstart
endif

"-------------------------------------------------------------------------------
" folding

"set foldenable
"set foldlevel=4
"set foldcolumn=4
"set foldmethod=indent

"let g:xml_syntax_folding=1
" ISSUE: JavaScript syntax folding doesn't work event you open it by setting
" javaScript_fold.
"let javaScript_fold=1

"syntax sync fromstart
"au FileType c,cpp,java,xml set foldmethod=syntax
"au FileType python set foldmethod=indent

"-------------------------------------------------------------------------------
" user interface

if has("mouse") | set mouse=a | endif

set showcmd " show (partial) command in the last line of the screen.
set showmode " TODO
set so=7 " number of lines to curor when moving vertically
" Show candidates in the statusline when using TAB to complete.
set wildmenu
set wildmode="list:longest"
set ruler
set cmdheight=2
set number
" Note: 'number' will be reset by setting 'relativenumber'.
"set relativenumber
set lazyredraw
set hidden " switch buffers without saving
" allow backspacing over everything in insert mode
set backspace=eol,start,indent
set whichwrap+=<,>,h,l

" The 'magic' option is on by default, but that isn't enough.
" I find 'very magic' is what I want and it makes pattern really easy to use.
" So, always insert a '\v' before the pattern to search to get 'very magic'.
" Here is a find-replace example from 'http://briancarper.net/blog/448/':
"   without magic:
"       :%s/^\%(foo\)\{1,3}\(.\+\)bar$/\1/
"   with very magic:
"       :%s/\v^%(foo){1,3}(.+)bar$/\1/
" :h /\v or :h magic
nnoremap / /\v
vnoremap / /\v

set ignorecase " always ignore since we have smartcase.
set smartcase
set incsearch
set gdefault " :%s/foo/bar/ -> :%s/foo/bar/g
set hlsearch
map <silent> <leader><CR> :noh<CR>
" <tab> is a lot easier to type than %.
nnoremap <tab> %
vnoremap <tab> %

set errorbells
set novisualbell

"set cursorline " highlight current line (make redrawing slower)
set showmatch " bracets
set matchtime=1 " 1/10 second to blink

set laststatus=2 " always show statusline

func! CurDir()
    return substitute(getcwd(), escape($HOME, '\'), "~", "")
endfunc

set laststatus=2 " always show statusline
set statusline=%<%f\ -\ %r%{CurDir()}%h\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\
        \ \ %-16.(%l/%L,%c%V%)\ \ %P
" Always set the cwd to the dir of current buffer.
" Similar to 'Link with Editor' of Package Explorer of Eclipse.
" TODO: This may make it difficult to generate tags/cscope_db.
"au BufEnter * :cd %:p:h

" Highlight unwanted spaces.
" See [http://vim.wikia.com/wiki/Highlight_unwanted_spaces]
" - highlight trailing whitespace in red
" - have this highlighting not appear whilst you are typing in insert mode
" - have the highlighting of whitespace apply when you open new buffers
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches() " for performance
" Using the list and listchars options:
func! ListOrNot()
    if &list
        set nolist
    else
        " TODO: :dig
        set list listchars=tab:>-,trail:-,eol:$,extends:>,precedes:<
"        set list listchars=tab:<-,trail:-,eol:$
    endif
endfunc
map <buffer> <leader>ls :call ListOrNot()<CR>

" Using syntax space errors.
"let c_space_errors = 1
"let java_space_errors = 1

"-----------------------------------------------------------------------------
" visual

" from an idea by Michael Naumann
func! VisualSearch(direction) range
    let l:saved_reg = @"
    exec "normal! vgvy"
    let l:pattern = escape(@", '\\/.*$^~[]')
    let l:pattern = substitute(l:pattern, "\n$", "", "")
    if a:direction == 'b'
        exec "normal ?" . l:pattern . "^M"
    else
        exec "normal /" . l:pattern . "^M"
    endif
    let @/ = l:pattern
    let @" = l:saved_reg
endfunc

" search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>

"-------------------------------------------------------------------------------
" window

map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

" vertically explore the dir of current file
"map <F2> :Vex<CR>
map <F2> :NERDTreeToggle<CR>

"-------------------------------------------------------------------------------
" buffer

" switch buffers with arrows
map <right> :bn<CR>
map <left>  :bp<CR>
map <up>    :bf<CR>
map <down>  :bl<CR>

" list buffers
map <leader>bl :ls<CR>
" add buffer
map <leader>ba :bad<space>
" delete buffer (write first)
map <leader>bd :w!<CR>:bd<CR>
" open a buffer for temporary use (e.g. copy)
map <leader>bt :e ~/tempbuf<CR>

map <leader>O :only<CR>

"-------------------------------------------------------------------------------
" tab
if v:version >= 700
    map <leader>tn :tabnew %<CR>
    map <leader>te :tabedit
    map <leader>tc :tabclose<CR>
    map <leader>tm :tabmove
    try
        set switchbuf=usetab
        set stal=2
    catch
    endtry
endif

"-------------------------------------------------------------------------------
" abbr.

iab xname Adam Gu
iab xmail sprinfall@gmail.com
iab xfile <c-r>=expand("%:t")<CR>

if exists("*strftime")
    " abbr. for date/time
    iab xdate <c-r>=strftime("%Y-%m-%d")<CR>
    iab xtime <c-r>=strftime("%H:%M:%S")<CR>
    " shortcut for date/time
    imap <buffer> <silent> <leader>d <c-r>=strftime("%Y %b %d %X")<CR>
endif

"-------------------------------------------------------------------------------

func! DeleteTrailingWS()
    exec "normal mz"
    " NOTE: [:%s/ \+$//] works for spaces only.
    %s/\s\+$//ge
    exec "normal `z"
endfunc

au BufWrite * :call DeleteTrailingWS()
map <leader>W :call DeleteTrailingWS()<CR>

" remove indenting on empty lines
map <F3> :%s/\s*$//g<CR>:noh<CR>''<CR>

"-------------------------------------------------------------------------------
" command line

func! DeleteTillSlash()
    let g:cmd = getcmdline()
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
    if g:cmd == g:cmd_edited
        let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
    endif
    return g:cmd_edited
endfunc

func! CurrentFileDir(cmd)
    return a:cmd . " " . expand("%:p:h") . "/"
endfunc

" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./

cno $q <C-\>eDeleteTillSlash()<CR>

cno $c e <C-\>eCurrentFileDir("e")<CR>

cno $tc <C-\>eCurrentFileDir("tabnew")<CR>
cno $th tabnew ~/
cno $td tabnew ~/Desktop/

"-------------------------------------------------------------------------------
" spelling check

if has("spell")
    func! SpellOrNot()
        if &spell != 0
            set nospell
        else
            set spell
        endif
    endfunc
    set spelllang=en_us
    map <buffer> <leader>sc :call SpellOrNot()<CR>
    map <leader>sn ]s
    map <leader>sp [s
    map <leader>sa zg
    map <leader>s? z=
endif

"-------------------------------------------------------------------------------
" FILE TYPES

" --- VIM ---
"au FileType vim map <buffer> <leader><space> :w!<CR>:source %<CR>
" TODO ':source' will highlight the last search string.
au FileType vim map <buffer> <leader><space> :source %<CR>

" --- LUA ---
au FileType lua map <buffer> <leader><space> :!lua %<CR>

" --- PYTHON ---

" On-the-fly python code checking:
"   pyflakes: http://www.vim.org/scripts/script.php?script_id=2441
" TODO
au FileType python map <buffer> <leader><space> :!python %<CR>

" Run in the Python interpreter.
func! Python_Eval_VSplit() range
   let src = tempname()
   let dst = tempname()
   exec ": " . a:firstline . "," . a:lastline . "w " . src
   exec ":!python " . src . " > " . dst
   exec ":pedit! " . dst
endfunc
"au FileType python vmap <F5> :call Python_Eval_VSplit()<CR>

" TODO
func! Run_python()
    :!python %
endfunc

"-------------------------------------------------------------------------------
" tool - ctags

" g:tags_dict = {
"     cpp : ['cpp1/tags', 'cpp2/tags', ...],
"     java : ['java1/tags', 'java2/tags', ...],
"     ...
" }
let g:tags_dict = {}
let g:tags_dict["all"] = []

" The environment variable 'ctags_db' is with format:
"   [c,cpp]path/to/stl_tags;[cpp]path/to/qt_tags;[java]path/to/java_tags;...
" This function parses it and save results in g:tags_dict.
func! ParseTagsFromEnvVar()
    if $CTAGS_DB == ""
        return
    endif
    let l:ctags_db_list = split($CTAGS_DB, ';')
    for l:ctags_db in l:ctags_db_list
        if strlen(l:ctags_db) == 0
            continue
        endif
        if l:ctags_db[0] == '['
            let l:i = stridx(l:ctags_db, ']')
            if l:i != -1
                let l:langs = split(strpart(l:ctags_db, 1, l:i-1), ',')
                let l:langs_tags = escape(expand(strpart(l:ctags_db, l:i+1)), ' ')
                for l:lang in l:langs
                    if !has_key(g:tags_dict, l:lang)
                        let g:tags_dict[l:lang] = []
                    endif
                    call add(g:tags_dict[l:lang], l:langs_tags)
                endfor
            endif
        else
            call add(g:tags_dict["all"], l:ctags_db)
        endif
    endfor
endfunc

func! AddTagsForFileType(ft)
    if (has_key(g:tags_dict, a:ft))
        for l:ft_tag in g:tags_dict[a:ft]
            if filereadable(l:ft_tag)
                exec 'set tags+='.l:ft_tag
            endif
        endfor
    endif
endfunc

func! AddTagsForAll()
    for l:o_tag in g:tags_dict["all"]
        if filereadable(l:o_tag)
            exec 'set tags+='.l:o_tag
        endif
    endfor
endfunc

" Execute ctags with options for the given filetype.
" @tags_path The path of the tags to generate.
" @files The path of a file or directory, absolute or not.
" @append Whether to use -a option of ctags.
func! ExecCtagsForFile(ft, tags_path, file_path, append)
    let l:ctags_cmd = "!ctags "
    if a:append != 0 " Append tags to existing tag file.
        let l:ctags_cmd = l:ctags_cmd."-a "
    endif
    let l:ctags_cmd = l:ctags_cmd."-f ".a:tags_path
    if a:ft == "cpp"
        let l:ctags_cmd = l:ctags_cmd." --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++ ".a:file_path
    else
        " TODO
        let l:ctags_cmd = l:ctags_cmd." --fields=+iaS --extra=+q ".a:file_path
    endif
    exec l:ctags_cmd
endfunc

" Execute ctags for a given directory.
" @tags_path The path of the tags to generate.
" @dir The directory.
func! ExecCtagsForDir(tags_path, dir, ctags_option)
    let l:ctags_cmd = "!ctags -f ".a:tags_path
    if !empty(a:ctags_option)
        let l:ctags_cmd = l:ctags_cmd." ".a:ctags_option
    endif
    exec l:ctags_cmd." -R ".a:dir
endfunc

" E.g., given '1/2/3', get '1/2'.
func! DirUpper(dir)
    let l:last_slash = strridx(a:dir, '/')
    if l:last_slash != -1
        return strpart(a:dir, 0, l:last_slash)
    else
        return ""
    endif
endfunc

" Generate tags for the given file in the upper directory where the file
" 'ctags.generate' is presented.
func! GenerateTagsForFile(file)
    let l:generated = 0
    let l:dir = DirUpper(a:file)
    while 1
        if empty(l:dir)
            break
        endif
        let l:genfile = l:dir."/ctags.generate"
        if filereadable(l:genfile)
            " Now we ignore the ctags option specified in file ctags.generate.
            " Note the tags path or files dir should be surrounded by "" ('' doesn't work).
            call ExecCtagsForFile(&ft, '"'.l:dir.'/tags"', '"'.a:file.'"', 1)
            let l:generated = 1
            break
        else
            let l:dir = DirUpper(l:dir)
        endif
    endwhile
    " Generate in current dir.
    if l:generated == 0
        let l:dir = DirUpper(a:file)
        call ExecCtagsForFile(&ft, '"'.l:dir.'/tags"', '"'.a:file.'"', 1)
    endif
    " Add the tags.
    exec 'set tags+='.escape(l:dir, ' ').'/tags'
endfunc

func! GenerateTagsForCurrentFile()
    return GenerateTagsForFile(expand("%:p"))
endfunc

" Generate tags in the upper directory where the file 'ctags.generate' is presented.
func! GenerateTagsForProj(dir)
    let l:dir = a:dir
    while 1
        if empty(l:dir)
            break
        endif
        let l:genfile = l:dir."/ctags.generate"
        if filereadable(l:genfile)
            let l:ctags_option = ""
            let l:line1 = readfile(l:genfile, "", 1)
            if !empty(l:line1)
                let l:ctags_option = l:line1[0]
            endif
            " Note the tags path or files dir should be surrounded by "" ('' doesn't work).
            " If ctags option is not specified, default is used.
            call ExecCtagsForDir('"'.l:dir.'/tags"', '"'.l:dir.'"', l:ctags_option)
            " Add the tags.
            exec 'set tags+='.escape(l:dir, ' ').'/tags'
            break
        else
            let l:dir = DirUpper(l:dir)
        endif
    endwhile
endfunc
func! GenerateTagsForCurrentProj()
    return GenerateTagsForProj(expand("%:p:h"))
endfunc

if filereadable($CTAGS_PATH)
    " TODO: This is meant to add the tags in CWD.
    if filereadable("tags")
        set tags+=tags
    endif

    " Load tags dictionary.
    call ParseTagsFromEnvVar()
    " Auto command to add tags by file type.
    au BufReadPost * :call CallOnce("AddTagsForFileType", [&ft])

    " Add other tags.
    call AddTagsForAll()

    map <silent> <F12> :call GenerateTagsForCurrentFile()<CR><CR>
    map <silent> <C-F12> :call GenerateTagsForCurrentProj()<CR><CR>
endif

"-------------------------------------------------------------------------------
" C/C++


" --- LISP, SCHEME ---
au FileType scheme :set lisp
au FileType scheme map <buffer> <leader><space> :!ypsilon %<CR>

"-------------------------------------------------------------------------------
" filetype - haskell

" use ghc funcality for haskell files
au Bufenter *.hs compiler ghc
setlocal includeexpr=substitute(v:fname,'\\.','/','g')
let g:haddock_browser = "C:/Documents and Settings/19003883/Local Settings/Application Data/Google/Chrome/Application/chrome.exe"
let g:haskell_home = "D:/bin/haskell-platform/2011.2.0.1/"
let g:ghc = g:haskell_home . "bin/ghc.exe"
let g:haddock_docdir = g:haskell_home . "doc/html/"
let g:wget = "wget.exe"

au FileType haskell call ExpandTab(2)
"au FileType haskell let b:ghc_staticoptions = '-isrc'
"au FileType haskell setlocal path += src

func! Bld_haskell()
    exec ":!ghc --make %"
    "-Wall
endfunc

func! Bld()
    return CallIf("Bld_".tolower(&filetype), [])
endfunc

func! Clr_haskell()
    " ISSUE: Windows only...
    return system("DEL *.hi *.o *.exe *.manifest")
endfunc
func! Clr()
    return CallIf("Clr_".tolower(&filetype), [])
endfunc

func! Run_haskell()
    exec ":!".expand("%:r")
endfunc
func! Run()
    return CallIf("Run_".tolower(&filetype), [])
endfunc

command! Bld call Bld()
command! Clr call Clr()
command! Run call Run()
nmap <F7> :Bld<CR>
nmap <C-F7> :Clr<CR>
nmap <F5> :Run<CR>

"-------------------------------------------------------------------------------
" tool - cscope

func! SetCScope()
    if !has("cscope") || !filereadable($CSCOPE_PATH)
        return
    endif

    set csprg=$CSCOPE_PATH
    " 0: search cscope db first; 1: search tag files first
    set csto=0 " default
    " search cscope db as well as the tag files
    set cst " default: nocst

    if filereadable("cscope.out")
        " add any database in current directory
        cs add cscope.out
        " else add database pointed to by environment
    elseif $CSCOPE_DB != ""
        let l:db_items = split($CSCOPE_DB, ';')
        for l:db_item in l:db_items
            if filereadable(l:db_item)
                exec "cs add ".l:db_item
            endif
        endfor
    endif

    " Tips for :cstag
    " :cstag can use the tag file produced by ctags while :cs find cannot
    " and if 'sct' is set, commands like <C-]> or :tag will use :cstag instead
    " of the default :tag behavior
    " so no extra mapping is provided here for :cstag. use <C-]> directly

    nmap <leader>S :cs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <leader>G :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <leader>C :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <leader>T :cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <leader>E :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <leader>F :cs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <leader>I :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <leader>D :cs find d <C-R>=expand("<cword>")<CR><CR>

    " Horizontally split window.
    nmap <leader><leader>S :scs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <leader><leader>G :scs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <leader><leader>C :scs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <leader><leader>T :scs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <leader><leader>E :scs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <leader><leader>F :scs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <leader><leader>I :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <leader><leader>D :scs find d <C-R>=expand("<cword>")<CR><CR>

    " Vertically split doesn't make much sense.

    " Update and add the cscope db.
    map <silent> <F11> :w<CR>:!cscope -Rbk *.h *.hpp *.cpp *.cc *.cxx *.C<CR>:cs add cscope.out<CR>
endfunc
" Use FileType since cscope is designed for C/C++.
au FileType c,cpp call CallOnce("SetCScope", [])

"-------------------------------------------------------------------------------
" PLUGIN - taglist

map <F8> :TlistToggle<CR>
let Tlist_Enable_Fold_Column = 1
let Tlist_File_Fold_Auto_Close = 1
let Tlist_Close_On_Select = 1
let Tlist_Show_Menu = 1
let Tlist_Sort_Type = "name"

"-------------------------------------------------------------------------------
" OMNI

set completeopt="menu" " no preview window.

" PLUGIN - OmniCppComplete
" TODO: Need to set 'path'.
"let OmniCpp_DefaultNamespaces = ["std", "boost"]
"let OmniCpp_NamespaceSearch = 2 " search in included files too.
let OmniCpp_ShowPrototypeInAbbr = 1 " display prototype in abbreviation.
let OmniCpp_SelectFirstItem = 2 " select first item without inserting.

"-------------------------------------------------------------------------------
" PLUGIN - matrix screensaver
"nmap <silent> <C-M> :Matrix<CR>

"-------------------------------------------------------------------------------
" PLUGIN - EnhancedCommentify
let g:EnhCommentifyMultiPartBlocks = 'yes'

" VIMIM
":let g:vimim_sexy_input_style=0


" SCons
au BufNewFile,BufRead SConstruct :set ft=python

